package com.wzy.netty.core.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * 描述  :
 * 创建人:    Wzy
 * 创建时间: 2020-06-11  13:26
 */
public class TestHttpServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        /*netty自带处理http的编码解码器，handler执行的顺序是添加的顺序*/
        pipeline.addLast("myHttpServerCodec", new HttpServerCodec());
        pipeline.addLast("myHttpHandler", new TestHttpServerHandler());

    }
}
